package com.esri.core.tasks.ags.geoprocessing;

import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import java.util.ArrayList;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class GPResultResource {
    private GPMessage[] messages;
    private GPParameter[] outputParameters;

    public GPParameter[] getOutputParameters() {
        return this.outputParameters;
    }

    public GPMessage[] getMessages() {
        return this.messages;
    }

    public static GPResultResource fromJson(JsonParser jsonParser) throws Exception {
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("Unable to parse the Response for this GPJobResource.");
        }
        GPResultResource gPResultResource = new GPResultResource();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("results".equals(currentName)) {
                if (jsonParser.getCurrentToken() != JsonToken.START_ARRAY) {
                    jsonParser.skipChildren();
                } else {
                    ArrayList arrayList = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        arrayList.add(GPParameter.createFromJson(jsonParser));
                    }
                    gPResultResource.outputParameters = (GPParameter[]) arrayList.toArray(new GPParameter[0]);
                }
            } else if ("messages".equals(currentName)) {
                if (jsonParser.getCurrentToken() != JsonToken.START_ARRAY) {
                    jsonParser.skipChildren();
                } else {
                    ArrayList arrayList2 = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        arrayList2.add(GPMessage.fromJson(jsonParser));
                    }
                    gPResultResource.messages = (GPMessage[]) arrayList2.toArray(new GPMessage[0]);
                }
            } else {
                jsonParser.skipChildren();
            }
        }
        return gPResultResource;
    }
}
